package com.ali.memory;

import java.lang.ref.SoftReference;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;

public class TestOOMPlus {
	public static void main(String[] args) throws Exception {
		List<ByteBuffer> a = new ArrayList();
		SoftReference<List> r = new SoftReference(a);
		a = null;
		try {
			for (int i = 0; i < 10000; i++) {
				ByteBuffer bb1 = ByteBuffer.allocate(1024 * 4);
				// Thread.sleep(4);
				if (r.get() != null)
					r.get().add(bb1);
				else {
					System.out.println("full gc, break");
					break;
				}
				// a.add(bb1);
			}
		} catch (Error e) {
			e.printStackTrace();
		}
		System.out.println("come on");
	}
}
